

var mainApp = angular.module('mainApp',["angular-popups","scService","ui.router","loginApp","userInfoApp","myOrderApp","orderPayApp","orderPayDetailApp","orderDetailApp","chargeStarted","charging","manualCode"]);
mainApp.config(function($urlRouterProvider,$stateProvider,$locationProvider){
	$stateProvider
	.state("orderPay",{
		url:"/orderPay/:orderNo",
		//template:"<p>hellow,miku</p>"
		templateUrl:"assets/scripts/app/orderPay/views/orderPay.html"
	})
	.state("paySuccess",{
		url:"/paySuccess/:orderNo",
		//template:"<p>hellow,miku</p>"
		templateUrl:"assets/scripts/app/orderPay/views/paySuccess.html"
	})
	.state("payFail",{
		url:"/payFail/:orderNo",
		//template:"<p>hellow,miku</p>"
		templateUrl:"assets/scripts/app/orderPay/views/payFail.html"
	})
	.state("orderPayDetail",{
		url:"/orderPayDetail/:orderNo",
		templateUrl:"assets/scripts/app/orderPayDetail/views/orderPayDetail.html"
	})	
	.state("orderDetail",{
		url:"/orderDetail/:orderNo",
		templateUrl:"assets/scripts/app/orderDetail/views/orderDetail.html"
	})	
	.state("login",{
		url:"/login/:code",
		templateUrl:"assets/scripts/app/login/views/login.html"
	})
	.state("userInfo",{
		url:"/userInfo",
		templateUrl:"assets/scripts/app/userInfo/views/userInfo.html"
	})
	.state("operation",{
		url:"/operation",
		templateUrl:"assets/scripts/app/userInfo/views/operation.html"
	})
	.state("myOrder",{
		url:"/myOrder",
		templateUrl:"assets/scripts/app/myOrder/views/myOrder.html"
	})	
	.state("notPay",{
		url:"/notPay",
		templateUrl:"assets/scripts/app/login/views/notPay.html"
	})
	// 扫码充电部分
	.state("chargeStarted",{
		url:"/chargeStarted",
		templateUrl:"assets/scripts/app/scanCharging/views/chargeStarted.html",
		controller:"chargeStartedController"
	})
	.state("charging",{
		url:"/charging",
		templateUrl:"assets/scripts/app/scanCharging/views/charging.html",
		controller:"chargingController"
	})
	.state("manualCode",{
		url:"/manualCode",
		templateUrl:"assets/scripts/app/scanCharging/views/manualCode.html",
		controller:"againScanController"
	})
	.state("errorScan",{
		url:"/errorScan",
		template:'<div class="mc-ct"><div class="mc-pic"><img src="assets/images/Icon_error@2x.png" alt=""><p class="fs18 color666 t-b">请扫描充电桩上二维码</p></div></div>'
	})

// 	$locationProvider.html5Mode({
//   enabled: true,
//   requireBase: false
// });
})

// weui
mainApp.controller('weuiCtrl',function($scope,$rootScope){
	//confirm类型
	$scope.confirmSet = function(confirm){
		var defailt_confirm = document.getElementById("defailt_confirm");
		defailt_confirm.style.display = "block";
		$scope.confirm = {
	        title:confirm.title,
	        content:confirm.content,
	        button:confirm.button
	    };
	}
	//Toast类型
	$scope.toastSet = function(toast){
		var defailt_toast = document.getElementById("defailt_toast");
		defailt_toast.style.display = "block";
		$scope.toast = {
	        content:toast.content,
	        kind:toast.kind
	    };
		setTimeout(function () {
	        defailt_toast.style.display = "none";
	    }, 2000);
	}

	//confirm扩展
	$scope.setConfirmEx = function(){
		var confirmEx = document.getElementById("confirmEx");
		confirmEx.style.display = "block";
	}

	// 双按钮confirm 退出确认退出
	$scope.weirdConfirmSet = function(weirdConfirm){
		var weird_confirm = document.getElementById("weird_confirm");
		weird_confirm.style.display = "block";
		$scope.weirdConfirm = {
			title:weirdConfirm.title,
			content:weirdConfirm.content,
			buttonAux:weirdConfirm.buttonAux,
			buttonMain:weirdConfirm.buttonMain
		}
	}

})
// 渲染模版
mainApp.directive('confirm',function(){
	return{
		restrict:'EA',
		templateUrl:'assets/scripts/plugins/weui-angular/default_confirm.html',
		replace:true,
		link:function(scope){
			scope.confirmHide = function(){
				var defailt_confirm = document.getElementById("defailt_confirm");
				defailt_confirm.style.display = "none";
			}
		}
	}
});
mainApp.directive('toast',function(){
	return{
		restrict:'EA',
		templateUrl:'assets/scripts/plugins/weui-angular/default_toast.html',
		replace:true
	}
});
//退出登录弹层指令
mainApp.directive('confirmEx',function(){
	return{
		restrict:'EA',
		templateUrl:'assets/scripts/plugins/weui-angular/confirmEx.html',
		replace:true,
		link:function(scope){
			scope.confirmExHide = function(){
				var confirmEx = document.getElementById("confirmEx");
				confirmEx.style.display = "none";
			};
		}
	}
});
mainApp.directive('weirdConfirm',function(){
	return{
		restrict:'EA',
		templateUrl:'assets/scripts/plugins/weui-angular/weird_confirm.html',
		replace:true,
		link:function(scope){
			scope.weirdConfirmHide = function(){
				var defailt_toast = document.getElementById("weird_confirm");
				defailt_toast.style.display = "none";				
			}
		}
	}
});


